package test_junit_shop.Customer;

import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.Select;
import util.BaseDriver;

public class WholesaleCustomer extends BaseDriver{

    private WholesaleCustomer() {
    }
    private static  WholesaleCustomer instance=new WholesaleCustomer();

    public static WholesaleCustomer getInstance(){
        return instance;
    }

    public void addWholesaleCustomer() throws InterruptedException {
        Thread.sleep(2000);
        driver=driver.switchTo().frame(2);
        driver.findElement(By.cssSelector("button.btn.btn-sm.btn-outline.btn-primary")).click();
        driver=driver.switchTo().frame(0);
        driver.findElement(By.name("name")).click();
        driver.findElement(By.name("name")).clear();
        driver.findElement(By.name("name")).sendKeys("moxiaojiang");

        driver.findElement(By.id("businessRange")).click();
        new Select(driver.findElement(By.id("businessRange"))).selectByVisibleText("汽车美容");
        driver.findElement(By.cssSelector("option[value=\"1\"]")).click();
        driver.findElement(By.name("fullName")).click();
        driver.findElement(By.name("fullName")).clear();
        driver.findElement(By.name("fullName")).sendKeys("测试");
        driver.findElement(By.name("shortName")).click();
        driver.findElement(By.name("shortName")).clear();
        driver.findElement(By.name("shortName")).sendKeys("测");
        driver.findElement(By.name("creditCode")).click();
        driver.findElement(By.name("creditCode")).clear();
        driver.findElement(By.name("creditCode")).sendKeys("0000");
        driver.findElement(By.name("officePhone")).click();
        driver.findElement(By.name("officePhone")).clear();
        driver.findElement(By.name("officePhone")).sendKeys("0775");
        driver.findElement(By.name("defaultAddress")).click();
        driver.findElement(By.name("defaultAddress")).clear();
        driver.findElement(By.name("defaultAddress")).sendKeys("湖南");
        driver.findElement(By.id("saleConsultant-id")).click();
        new Select(driver.findElement(By.id("saleConsultant-id"))).selectByVisibleText("yya");
        driver.findElement(By.cssSelector("option[value=\"90\"]")).click();

        driver=driver.switchTo().parentFrame();
        driver.findElement(By.linkText("确定")).click();
    }


    public void deleteWholesaleCustomer() throws InterruptedException {
        Thread.sleep(5000);
        driver.findElement(By.name("btSelectItem")).click();
        Thread.sleep(1000);
        driver.findElement(By.cssSelector("button.btn.btn-sm.btn-outline.btn-danger")).click();
        Thread.sleep(2000);
        driver.findElement(By.linkText("确定")).click();
    }

}
